// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import './util/res.js';

Vue.config.productionTip = false
Vue.use(ElementUI);
axios.defaults.baseURL="http://124.70.144.177:8888";
Vue.prototype.$axios=axios;

Vue.config.productionTip = false
axios.interceptors.response.use(response => {
  if(response.data.code ==='500'){
    localStorage.removeItem("loginMes");
    router.push("/login");
  }
  return response;
}, error => {
  if(error.response.data.code ==='500'){
    localStorage.removeItem("loginMes");
    router.push("/login");
  }
  if(error.response.status === 500 || error.response.status === 403){
    const data = error.response.data;
    localStorage.removeItem("loginMes");
    router.push("/login");
    return error
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
